//
//  CZSearchView.swift
//  WeiBo
//
//  Created by Apple on 16/9/13.
//  Copyright © 2016年 KY. All rights reserved.
//

import UIKit


//  搜索视图

class CZSearchView: UIView {

    @IBOutlet weak var searchTextField: UITextField!
    
    @IBOutlet weak var btnSearch: UIButton!
    
    @IBOutlet weak var searchTextFieldRightConstaint: NSLayoutConstraint!
    
    
    
    //  通过xib创建对象
    class func searchView() -> CZSearchView {
        
        return UINib(nibName: "CZSearchView", bundle: nil).instantiate(withOwner: nil, options: nil).last! as! CZSearchView
        
    }
    
    
    @IBAction func btnSearchAction(_ sender: AnyObject) {
    
        searchTextField.resignFirstResponder()
        searchTextFieldRightConstaint.constant = 0
        UIView.animate(withDuration: 0.25) { 
            self.layoutIfNeeded()
        }
    
    }
    
    @IBAction func beginEditAtion(_ sender: AnyObject) {
        
        searchTextFieldRightConstaint.constant = btnSearch.frame.size.width
        
        //  加上动画
        UIView.animate(withDuration: 0.25) { 
            self.layoutIfNeeded()
        }
        
        
    }
    
    
    
    
    
    
    

}
